package com.weixing.mall.provider.model.vo.report.storage;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.core.enums.OrderSysTagEnum;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.enums.OrderStateEnum;
import com.weixing.mall.provider.support.excel.EnumConverter.OrderStatusConverter;
import com.weixing.mall.provider.support.excel.EnumConverter.OrderSysTagConverter;
import com.weixing.mall.provider.support.excel.EnumConverter.OrderTypeConverter;
import com.weixing.mall.util.SKUUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * @author jzy
 * @date 2020/6/6
 */
@Data
@Accessors(chain = true)
@ApiModel(value="StorageExchangeReport2Vo", description="05仓储部-换货报表2")
@ContentRowHeight(40)
public class StorageExchangeReport2Vo {
    @ApiModelProperty(value = "订单编号")
    @ExcelProperty("订单编号")
    private String orderSn;
    @ApiModelProperty(value = "客户名")
    @ExcelProperty("客户名")
    private String contactUser;
    @ApiModelProperty(value = "手机号")
    @ExcelProperty("手机号")
    private String contactPhone;
    @ApiModelProperty(value = "所属代理")
    @ExcelProperty("所属代理")
    private String agentName;
    @ApiModelProperty(value = "所属客服")
    @ExcelProperty("所属客服")
    private String customerName;
    @ApiModelProperty(value = "所属发货员")
    @ExcelProperty("所属发货员")
    private String shipperName;
    @ApiModelProperty(value = "货号")
    @ExcelProperty("货号")
    private String goodsSn;

    @ApiModelProperty(value = "图片")
    @ExcelIgnore
    private String goodsImg;
    @ExcelProperty("商品图片")
    @ColumnWidth(10)
    private URL goodsImgUrl;

    @ApiModelProperty(value = "颜色/尺码")
    @ExcelProperty("颜色/尺码")
    @ExcelIgnore
    private String skuDesp;
    @ApiModelProperty(value = "颜色")
    @ExcelProperty("颜色")
    private String color;
    @ApiModelProperty(value = "尺码")
    @ExcelProperty("尺码")
    private String size;

    @ApiModelProperty(value = "原颜色/尺码")
    @ExcelProperty("原颜色/尺码")
    @ExcelIgnore
    private String chagSkuDesp;
    @ApiModelProperty(value = "原颜色")
    @ExcelProperty("原颜色")
    private String chagColor;
    @ApiModelProperty(value = "原尺码")
    @ExcelProperty("原尺码")
    private String chagSize;

    @ApiModelProperty(value = "分类")
    @ExcelProperty("分类")
    private String actName;

    @ApiModelProperty(value = "活动名称")
    @ExcelProperty("活动名称")
    private String catName;

    @ApiModelProperty(value = "下单时间")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("下单时间")
    private Date createdTime;
    @ApiModelProperty(value = "审核时间")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("审核时间")
    private Date auditTime;
    @ApiModelProperty(value = "接收时间")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("接收时间")
    private Date receiveTime;
    @ApiModelProperty(value = "发货时间")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("发货时间")
    private Date shipTime;

    @ApiModelProperty(value = "订单类型")
    @ExcelProperty(value = "订单类型",converter = OrderTypeConverter.class)
    private OrderTypeEnum orderType;
    @ApiModelProperty(value = "标签状态")
    @ExcelProperty(value = "标签状态",converter = OrderSysTagConverter.class)
    private OrderSysTagEnum sysTag;
    @ApiModelProperty(value = "订单状态")
    @ExcelProperty(value = "订单状态",converter = OrderStatusConverter.class)
    private OrderStateEnum orderStatus;

    @ApiModelProperty(value = "订单ID")
    @ExcelIgnore
    private Long orderId;
    @ApiModelProperty(value = "售后ID")
    @ExcelIgnore
    private Long afterSaleId;


    public void setGoodsImg(String goodsImg) {
        this.goodsImg = goodsImg;
        try {
            if (StrUtil.isNotEmpty(goodsImg)){
                this.goodsImgUrl =new URL(GlobalConstant.IMG_PATH_URL +goodsImg+GlobalConstant.IMG_PATH_URL_SUFFIX);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    private void setSkuDesp(String skuDesp){
        this.skuDesp = skuDesp;
        if (StrUtil.isNotEmpty(skuDesp)){
            this.color = SKUUtils.color2(skuDesp);
            this.size = SKUUtils.size2(skuDesp);
        }
    }

    private void setChagSkuDesp(String chagSkuDesp){
        this.chagSkuDesp = chagSkuDesp;
        if (StrUtil.isNotEmpty(chagSkuDesp)){
            this.chagColor = SKUUtils.color2(chagSkuDesp);
            this.chagSize = SKUUtils.size2(chagSkuDesp);
        }
    }
}
